-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refresh during destroy #27408
Refresh during destroy #27408
Conversation
Codecov Report
|
Because the destroy plan only creates the necessary changes for apply to remove all the resources, it does no reading of resources or data sources, leading to stale data in the state. In most cases this is not a problem, but when a provider configuration is using resource values, the provider may not be able to run correctly during apply. In prior versions of terraform, the implicit refresh that happened during `terraform destroy` would update the data sources and remove missing resources from state as required. The destroy plan graph has a minimal amount of information, so it is not feasible to work the reading of resources into the operation without completely replicating the normal plan graph, and updating the plan graph and all destroy node implementation is also a considerable amount of refactoring. Instead, we can run a normal plan which is used to refresh the state before creating the destroy plan. This brings back similar behavior to core versions prior to 0.14, and the refresh can still be skipped using the `-refresh=false` cli flag.
These tests were not previously running a refresh, and hence did not expect the resources to be read.
get rid of the mutation of the plans.Plan and return values.
84ff97d
to
fb2208a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 makes sense to me! There are some really nice var name and comment updates in here, thank you!
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Because the destroy plan only creates the necessary changes for apply to
remove all the resources, it does no reading of resources or data
sources, leading to stale data in the state. In most cases this is not a
problem, but when a provider configuration is using resource values, the
provider may not be able to run correctly during apply. In prior
versions of terraform, the implicit refresh that happened during
terraform destroy
would update the data sources and remove missingresources from state as required.
The destroy plan graph has a minimal amount of information, so it is not
feasible to work the reading of resources into the operation without
completely replicating the normal plan graph, and updating the plan
graph and all destroy node implementations is also a considerable amount
of refactoring. Instead, we can run a normal plan which is used to
refresh the state before creating the destroy plan. This brings back
similar behavior to core versions prior to 0.14, and the refresh can
still be skipped using the
-refresh=false
cli flag.Fixes #27172